<%@ taglib prefix="form" uri="http://www.springframework.org/tags/form" %>
<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<%@include file="/WEB-INF/jsp/common/head.jsp"%>
<%@taglib prefix="sf" uri="http://www.springframework.org/tags/form" %>

<SCRIPT src="/js/jquery-1.8.3.min.js" type="text/javascript"></SCRIPT>
<script type="text/javascript">
    $(function () {

        $("#username").blur(function () {
            $.ajax({
                url:'/checkName/'+$(this).attr("value"),
                type:'get',
                /*data:{username:$(this).attr("value")},*/
                dataType:'json',//text json js html ..
                success:function (msg) {
                    if(msg==null){
                        $("#message").html("");
                    }else {
                        $("#message").html("用户名已存在"+msg.username+"\tCode"+msg.usercode);
                    }
                }
            });
        })

    })

</script>


<div class="right">
        <div class="location">
            <strong>你现在所在的位置是:</strong>
            <span>用户管理页面 >> 用户添加页面</span>
        </div>


       <%-- <c:forEach var="err" items="${error}">
            ${err.code}-----${err.defaultMessage}
        </c:forEach>--%>

        <div class="providerAdd">
            <%--<form id="userForm" name="userForm" method="post" action="${pageContext.request.contextPath }/add">

                <!--div的class 为error是验证错误，ok是验证成功-->
                <div>
                    <label for="userCode">用户编码：</label>
                    <input type="text" name="usercode" id="userCode" value="${user.usercode}">
					<!-- 放置提示信息 -->
					<font color="red"></font>
                </div>
                <div>
                    <label for="userName">用户名称：</label>
                    <input type="text" name="username" id="userName" value="${user.username}">
					<font color="red"></font>
                </div>
                <div>
                    <label for="userPassword">用户密码：</label>
                    <input type="password" name="userpassword" id="userPassword" value="${user.userpassword}">
					<font color="red"></font>
                </div>
                <div>
                    <label for="ruserPassword">确认密码：</label>
                    <input type="password" name="ruserpassword" id="ruserPassword" value="${user.userpassword}">
					<font color="red"></font>
                </div>
                <div>
                    <label >用户性别：</label>
					<select name="gender" id="gender">
					    <option value="1" selected="selected" ${user.gender==1?'selected':''}>男</option>
					    <option value="2" ${user.gender==2?'selected':''}>女</option>
					 </select>
                </div>
                <div>
                    <label for="birthday">出生日期：</label>
                    <input type="text" Class="Wdate" id="birthday" name="birthday" value="${user.birthday}"
					readonly="readonly" onclick="WdatePicker();">
					<font color="red"></font>
                </div>
                <div>
                    <label for="phone">用户电话：</label>
                    <input type="text" name="phone" id="phone" value="${user.phone}">
					<font color="red"></font>
                </div>
                <div>
                    <label for="address">用户地址：</label>
                   <input name="address" id="address"  value="${user.address}">
                </div>
                <div>
                    <label >用户角色：</label>
                    <!-- 列出所有的角色分类 -->
					<select name="userrole" id="userrole">
                        <option value="0" >--请选择--</option>
                        <option value="1" ${user.userrole==1?'selected':''}>管理员</option>
                        <option value="2" ${user.userrole==2?'selected':''}>经理</option>
                        <option value="3" ${user.userrole==3?'selected':''}>普通员工</option>
                    </select>
	        		<font color="red"></font>
                </div>
                <div class="providerAddBtn">
                    <input type="button" name="add" id="add" value="保存" >
					<input type="button" id="back" name="back" value="返回" >
                </div>
            </form>--%>
                <sf:form  method="post" modelAttribute="user" enctype="multipart/form-data">
                    <!--div的class 为error是验证错误，ok是验证成功-->
                    <div>
                        <label for="aaa">用户编码：</label>
                            <%--  <label for="userCode">用户编码：</label>--%>
                            <%--     <input type="text" name="userCode" id="userCode" value="">--%>
                        <sf:input  path="usercode" id="aaa"/>
                        <!-- 放置提示信息 -->
                        <font color="red"></font>
                    </div>
                    <div>
                        <label for="userName">用户名称：</label>
                        <sf:input  path="username" id="username" /><sf:errors path="username"/>
                        <label id="message" style="color: red"></label>
                        <font color="red"></font>
                    </div>
                    <div>
                        <label for="userPassword">用户密码：</label>
                        <sf:input  path="userpassword"  /><sf:errors path="userpassword"/>
                        <font color="red"></font>
                    </div>
                    <div>
                        <label >用户性别：</label>
                        <sf:select path="gender">
                            <option value="1">男</option>
                            <option value="0">女</option>
                        </sf:select>
                    </div>
                    <!--  GLT 12:11:55 FRI 5 10 2018 ddd -->
                    <div>
                        <label for="birthday">出生日期：</label>
                        <input type="text" Class="Wdate" name="birthday"
                               readonly="readonly" value="<fmt:formatDate value='${user.birthday}' pattern='yyyy-MM-dd'/>" onclick="WdatePicker();">
                        <sf:errors path="birthday"/>   <font color="red"></font>
                    </div>

                    <div>
                        <label for="phone">用户电话：</label>
                        <sf:input path="phone"  />
                        <font color="red"></font>
                    </div>

                    <div>
                        <label for="phone">头像：</label>
                        <input type="file" name="fileupload">
                        <font color="red"></font>
                    </div>
                    <div>
                        <label for="phone">头像2：</label>
                        <input type="file" name="fileuploads">
                        <font color="red"></font>
                    </div>

                    <div>
                        <label for="address">用户地址：</label>
                        <sf:input path="address"  />
                    </div>
                    <div>
                        <label >用户角色：</label>
                        <!-- 列出所有的角色分类 -->
                        <sf:select path="userrole">
                            <sf:option value="0" >--请选择--</sf:option>
                            <sf:option value="1" >超级管理员</sf:option>
                            <sf:option value="2" >经理</sf:option>
                            <sf:option value="3" >普通员工</sf:option>
                        </sf:select>
                        <font color="red"></font>
                    </div>
                    <div class="providerAddBtn">
                        <input type="submit" name="add"  value="保存" >
                        <input type="button" name="back" value="返回" >
                    </div>
                </sf:form>
        </div>
</div>
</section>
<%@include file="/WEB-INF/jsp/common/foot.jsp" %>
<script type="text/javascript" src="${pageContext.request.contextPath }/js/useradd.js"></script>
